#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDebug>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QTimer>
#include <QComboBox>
#include <QPainter>
#include <QTime>
#include <math.h>
#include <QMessageBox>
#include <QThread>
#include "serialthread.h"

extern int LINECOUNT;
extern int CIRCLECOUNT;
extern int SHOWDISTANCE;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = Q_NULLPTR);
    ~MainWindow();
    QPixmap paintWidget();

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent(QResizeEvent *event);

private slots:
    void on_OpenSerialButton_clicked();
//    void ReadData();
    void UpdatePort();//更新端口号
    void timerTimeOut();
    void on_cleanButton_clicked();
    void on_hexBox_stateChanged(int arg1);
    void on_showData(QByteArray value,int index,int data0,int data1,int data2,int data3);
    void on_showErrorData(char);
    void on_showMsgBox(void);
    void on_SetButton_clicked();

private:
    Ui::MainWindow *ui;
    QSerialPort *serial;            //串口
    SerialThread *mthread;

    QTimer *timer;                  //获取可用串口定时器
    QTimer *p_timer;                //更新图片定时器
    QStringList oldPortStringList;  //存储旧的串口
    QPoint point;

    QPointF points[COUNTSIZE];
    int i_diameter=0;
    double d_angle=0;
    int showFlag=0;
    QList<QPixmap>  list_pixmap;
    QString showbuf;
};

#endif // MAINWINDOW_H
